﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace UTC_Project_Manager.Model.Infrastructure
{
    public class ProjectTask
    {

        public ProjectTask() { }

        private TimeSpan effort;
        private TimeSpan completedEffort;
        private TimeSpan duration;

        #region Properties
        public String IndexString { get; set; }
        public String Content { get; set; }
        public String PredecessorsString { get; set; }
        public String AssignmentsString { get; set; } // Name of members

        public DateTime Start { get; set; }
        public DateTime Finish { get; set; }
        [XmlIgnore]
        public TimeSpan Effort { get { return effort; } set { effort = value; } }
        [XmlIgnore]
        public TimeSpan CompletedEffort { get { return completedEffort; } set { completedEffort = value; } }
        [XmlIgnore]
        public TimeSpan Duration { get { return duration; } set { duration = value; } }

        public double Completion { get; set; }
        public int Indentation { get; set; }

        public bool IsExpanded { get; set; }
        public bool IsCompleted { get; set; }
        public bool IsMilestone { get; set; } // For the reunions!

        public String Description { get; set; }
        public String Note { get; set; }
        
        #endregion

        // Pretend property for serialization
        [XmlElement("Effort")]
        public long EffortTicks
        {
            get { return effort.Ticks; }
            set { effort = new TimeSpan(value); }
        }

        // Pretend property for serialization
        [XmlElement("CompletedEffort")]
        public long CompletedEffortTicks
        {
            get { return completedEffort.Ticks; }
            set { completedEffort = new TimeSpan(value); }
        }

        // Pretend property for serialization
        [XmlElement("Duration")]
        public long DurationTicks
        {
            get { return duration.Ticks; }
            set { duration = new TimeSpan(value); }
        }

        public override String ToString()
        {
            return Content;
        }
    }
}